<?php

/*
 * litchicms
 * Copyright (C) ${date} Author: tiefa(539247@qq.com)
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
!defined('BRK') && exit("!");

if (!function_exists('Component_ui_title')) {

    function Component_ui_title($arr=FALSE) {
        !$arr && exit('Component_ui_title');

        $input = input_text_control('title', $arr['collection_value'], 'title');
        return "
    <div class='content_group_row'>
        <table class='thetable' border='0' cellpadding='0' cellspacing='1'>
            <tr>
                <td class='td1' bgcolor='#ffffff'>
                    <div>
                        <div class='cname'><b>标题</b>:</div>
                        <div class='cdesc'>文章标题...</div>
                    </div>
                </td>
                <td class='td2' >
                    <div>
                    $input
                    </div>
                </td>
            </tr>
        </table>
    </div>
    ";
    }

}

$BRK_GLOBAL['ComponentValidationFunction'][] = 'Component_Validation_title';

if (!function_exists('Component_Validation_title')) {

    function Component_Validation_title() {
        !key_exists('title', $_POST['field']) && exit("KEY title IS NOT EXISTS IN ARRAY \$_POST['field']");

        if (empty($_POST['field']['title'])) {
            return "标题不可以为空";
        }

        return TRUE;
    }

}